<?php
require_once "resources/inc/header.php";
?>
<div id="wrap"> 
<!--<script type="text/javascript" src="resources/third-party/editarea_0_8_2/edit_area/edit_area_full.js"></script> -->
<script type="text/javascript">
//<![CDATA[
/*
editAreaLoader.init({
	id : "editor_window"		
	,syntax: "php"	
	,start_highlight: true
	,allow_toggle: false
	,word_wrap: true
	,language: "en"
	,onload: function(){
		alert("hi");
	}

}); */
//]]>
</script>

<div id="leftpanel">
<h1 id="hint_">HINT</h1>
<div id="hint" class="content-box" style="height:70px; overflow-y:scroll">
 Realtime Hint is enabled.
</div>
<h1 id="help_">HELP</h1>
<div id="help" class = "content-box" style="height:170px; overflow-y:scroll">
 Realtime Help is enabled.
</div>

<h1 id="apilist_">API REFERENCE</h1> 
<div id="apilist" class = "content-box" style="height:80px; padding-top:5px; overflow-y:scroll">
<table style="vertical-align:text-top;">
<tr>
<td>
<?php
$sql = "SELECT id, api_name FROM apis";
$resultAPIs = @mysql_query($sql);
if(!$resultAPIs){
	DIE ('Failed to load API list');
}
while($api = mysql_fetch_array($resultAPIs)){
	print $api['api_name'];
	print '<br/>';
}
?>


</td>
</tr>
</table>

</div>
</div>
<div id="centerpanel">
<h1 id="editor_h1"> EDITOR WINDOW </h1>

<div id="editor_container" class = "content-box" style="height:400px; overflow:hidden; text-align:left; background-color:#FFFFFF; padding-left:0px; ">
<textarea id="editor_window" style="width:95%; height:100%; overflow-y:scroll; margin-left:25px; padding-left:15px;" rows="100" cols="80"
onkeyup="showHint(this.value);
showHelp(this.value);
showExamples(this.value);"
onselect="showHint(this.value.substr(this.selectionStart, (this.selectionEnd - this.selectionStart)));
showHelp(this.value.substr(this.selectionStart, (this.selectionEnd - this.selectionStart)));
showExamples(this.value.substr(this.selectionStart, (this.selectionEnd - this.selectionStart)));
search(this.value.substr(this.selectionStart, (this.selectionEnd - this.selectionStart)));">
</textarea>
</div>
</div>
<div id="rightpanel">
<div>
<input type="text" id="example-search-text-box" name="Blueprint Realtime Search" value="Blueprint Realtime Search"
 style = "color:GRAY; font-style:italic; width:98%; height:20px; margin-bottom:5px;" 
 onclick = "this.value=&quot;&quot;; this.style.color=&quot;BLACK&quot;; this.style.fontStyle=&quot;normal&quot;;"
 onblur = "this.value=&quot;Blueprint Realtime Search&quot;; this.style.color=&quot;GRAY&quot;; this.style.fontStyle=&quot;italic&quot;;"
 onkeyup = "showExamples(this.value); showHelp(this.value); search(this.value);" />
</div>

<h1 id="examples_">EXAMPLES</h1>

<div id="examples" class = "content-box" style="height:369px; overflow-y:scroll;">
 Realtime Example Support is enabled.
</div>

</div>
<table style="margin-right:20px;">
<tr>
<td class="content" style="valign:top; width:60%">
  <div id="content">
    <div id="searchResults">Loading...</div>
  </div>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
//<![CDATA[
function highlight(str)
{
if (str.length==0)
  { 
  //document.getElementById("editor_window").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  this.xmlhttp_h=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp_h=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp_h.onreadystatechange=function()
  {
  if (xmlhttp_h.readyState==4 && xmlhttp_h.status==200)
    {
    document.getElementById("editor_window").innerHTML= xmlhttp_h.responseText;
    }
  }
	
xmlhttp_h.open("GET","web/ajax/highlight.php?q="+str,true);
xmlhttp_h.send();
}

function showHint(str)
{
this.tokens = encodeURIComponent(str);
this.lines = tokens.split("%0A");
this.words = lines[lines.length-1].split("%20");
if (lines[lines.length-1]==0 || words[words.length-1]==0)
  { 
  //document.getElementById("examples").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  this.xmlhttp_apis=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp_apis=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp_apis.onreadystatechange=function()
  {
  if (xmlhttp_apis.readyState==4 && xmlhttp_apis.status==200)
    {
		if(document.getElementById("examples").innerHTML!=""){
    	document.getElementById("hint").innerHTML=xmlhttp_apis.responseText;
		}
    }
  }
this.queryString = "q1="+words[words.length-1]+"&q2="+lines[lines.length-1];
xmlhttp_apis.open("GET","web/ajax/hint.php?"+this.queryString,true);
xmlhttp_apis.send();
}


function showHelp(str)
{
this.tokens = encodeURIComponent(str);
this.lines = tokens.split("%0A");
this.words = lines[lines.length-1].split("%20");
if (lines[lines.length-1]==0 || words[words.length-1]==0)
  { 
  //document.getElementById("examples").innerHTML="";
  return;
  }

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  this.xmlhttp_help=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp_help=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp_help.onreadystatechange=function()
  {
  if (xmlhttp_help.readyState==4 && xmlhttp_help.status==200)
    {
		if(document.getElementById("examples").innerHTML!=""){
    		document.getElementById("help").innerHTML=xmlhttp_help.responseText;
		}
    }
  }
	
this.queryString = "q1="+words[words.length-1]+"&q2="+lines[lines.length-1];
xmlhttp_help.open("GET","web/ajax/help.php?"+queryString,true);
xmlhttp_help.send();
}

function showExamples(str)
{
this.tokens = encodeURIComponent(str);
this.lines = tokens.split("%0A");
this.words = lines[lines.length-1].split("%20");
if (lines[lines.length-1]==0 || words[words.length-1]==0)
  { 
  //document.getElementById("examples").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  this.xmlhttp_examples=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp_examples=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp_examples.onreadystatechange=function()
  {
  if (xmlhttp_examples.readyState==4 && xmlhttp_examples.status==200)
    { 
		if(document.getElementById("examples").innerHTML!=""){
			document.getElementById("examples").innerHTML=xmlhttp_examples.responseText;
		}
    }
  }
	
this.queryString = "q1="+words[words.length-1]+"&q2="+lines[lines.length-1];
xmlhttp_examples.open("GET","web/ajax/examples.php?"+queryString,true);
xmlhttp_examples.send();
}
//]]>
//createTextAreaWithLines("editor_window");
</script>
 
<?php
require_once "resources/inc/footer.php";
?>

